/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sv.com.dizucar.convertidor;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import sv.com.dizucar.controlador.PaisControlador;
import sv.com.dizucar.modelo.Pais;

/**
 *
 * @author stefanny
 */
@FacesConverter(forClass=Pais.class)
public class PaisConvertidor implements Converter{

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        PaisControlador controlador = new PaisControlador();
        Integer id = Integer.parseInt(value);
        return controlador.encontrarEntidad(id);
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        return ((Pais) value).getIdpais().toString();
    }
    
}
